package com.breezelin.card.app.adapterview;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import com.breezelin.card.app.Constants;
import com.breezelin.card.app.R;
import com.breezelin.card.adapterview.model.CardModel;
import com.breezelin.card.adapterview.model.Orientations;
import com.breezelin.card.adapterview.view.CardContainer;

import java.util.ArrayList;

public class CardAdapterViewActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_card_adapter_view);

        CardContainer cardContainer = (CardContainer) findViewById(R.id.cards);
        // 看看传来了什么排布方式
        Orientations.Orientation orientation = Orientations.Orientation.Ordered;
        switch (getIntent().getIntExtra(Constants.Key.ORIENTATION, Constants.Orientation.Ordered)) {
            case Constants.Orientation.Ordered:
                orientation = Orientations.Orientation.Ordered;
                break;
            case Constants.Orientation.Disordered:
                orientation = Orientations.Orientation.Disordered;
                break;
            case Constants.Orientation.Lined:
                orientation = Orientations.Orientation.Lined;
                break;
        }
        cardContainer.setOrientation(orientation);

        ArrayList<CardModel> models = new ArrayList<>();
        CardModel model = new CardModel();
        for (int i = 0; i < 500; i++) {
            models.add(model);
        }

        cardContainer.setAdapter(new CardAdapter(this, models));
    }
}
